package com.efeichong.project.controller;

import com.efeichong.common.PageData;
import com.efeichong.common.domain.ResponseData;
import com.efeichong.project.domain.vo.SysDictDetailVo;
import com.efeichong.project.service.SysDictDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author
 * @date 2020/11/25
 * @description 数据字典明细
 */
@Api(tags = "数据字典明细接口", value = "数据字典明细接口")
@RestController
@RequestMapping("/sysDictDetail")
@RequiredArgsConstructor
public class SysDictDetailController {

    private final SysDictDetailService sysDictDetailService;

    @ApiOperation(value = "数据字典明细详细")
    @GetMapping(value = "/getInfo")
    public ResponseData<SysDictDetailVo> getInfo(@RequestParam("id") Long id) {
        return new ResponseData(sysDictDetailService.getInfo(id));
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "第几页开始", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "每页行数", paramType = "query", dataTypeClass = Integer.class)
    })
    @ApiOperation(value = "数据字典明细分页查询")
    @GetMapping("/page")
    public ResponseData<PageData<SysDictDetailVo>> page(SysDictDetailVo sysDictDetailVo) {
        return new ResponseData(sysDictDetailService.selectByPage(sysDictDetailVo));
    }

    @ApiOperation(value = "数据字典明细新增")
    @PostMapping("insert")
    public ResponseData insert(@RequestBody SysDictDetailVo sysDictDetailVo) {
        sysDictDetailService.insertSysDictDetail(sysDictDetailVo);
        return new ResponseData();
    }

    @ApiOperation(value = "数据字典明细编辑")
    @PostMapping("update")
    public ResponseData update(@RequestBody SysDictDetailVo sysDictDetailVo) {
        sysDictDetailService.updateSysDictDetail(sysDictDetailVo);
        return new ResponseData();
    }

    @ApiOperation(value = "数据字典明细批量删除")
    @GetMapping("/deleteByIds")
    public ResponseData deleteSysDictDetailByIds(@RequestParam("ids") List<Long> ids) {
        sysDictDetailService.deleteByIds(ids);
        return new ResponseData();
    }

    @ApiOperation(value = "数据字典明细删除")
    @GetMapping("/deleteById")
    public ResponseData deleteSysDictDetailById(@RequestParam("id") Long id) {
        sysDictDetailService.deleteById(id);
        return new ResponseData();
    }

}
